Skip to content

Conversation

@mstoykov
Copy link
Contributor

@mstoykov mstoykov commented Oct 17, 2025

What?

Reimplement auto extension resolution without using esbuild or k6deps, but the internal methods that k6 uses to load modules.

Why?

This removes the need for a separate project to have the same way to parse and understand imports and also double parsing everything.

Also fixing a number of bugs coming from this and removes the maintaince burden to keep both projects align.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Based on #5240 and requires #5319 to have the same functionality as the same.

Fixes #5127
FIxes #5176
Fixes #5104
Closes #5102
Requirement for #5166 ( likely a future PR that refactors more of test_load.go)

Likely some updates to every other issue around automatic extension resolution as well.

@mstoykov mstoykov added this to the v1.4.0 milestone Oct 17, 2025
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 17, 2025 15:59 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 17, 2025 16:09 — with GitHub Actions Inactive
@mstoykov mstoykov force-pushed the basicNativeNativeBinaryProvisioning branch from 5c93d1d to d738041 Compare October 21, 2025 10:34
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 21, 2025 10:41 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 21, 2025 10:45 — with GitHub Actions Inactive
@mstoykov mstoykov marked this pull request as ready for review October 21, 2025 10:47
@mstoykov mstoykov requested a review from a team as a code owner October 21, 2025 10:47
@mstoykov mstoykov requested review from ankur22, codebien, oleiade and pablochacin and removed request for a team October 21, 2025 10:47
@mstoykov
Copy link
Contributor Author

This likely should get more tests, and either drop the launcher.go and the old way or to further make it possible to use the old resolution method ... for now at least.

But I would like some initial feedback and thoughts.

constraints := string(match[idxUseConstraints])

if _, ok := deps[extension]; ok {
return deps, fmt.Errorf("already had a use directivce for %q", extension)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return deps, fmt.Errorf("already had a use directivce for %q", extension)
return deps, fmt.Errorf("already had a use directive for %q", extension)

Is this printed to the user? Can we make it a bit more user friendly? I guess if this appears out of nowhere the user is not getting it fast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see it now.

Base automatically changed from allUnknownModulesDetection to master October 21, 2025 14:17
@mstoykov mstoykov force-pushed the basicNativeNativeBinaryProvisioning branch from 65afd95 to c8e52fa Compare October 22, 2025 08:56
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 22, 2025 09:04 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 22, 2025 09:06 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 22, 2025 09:17 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 22, 2025 09:19 — with GitHub Actions Inactive
Copy link
Contributor

@pablochacin pablochacin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just gave a first pass and centered my comments on the structure of the code.

I find it unintuitive that we use an error for actually handling the missing dependencies. I would prefer if we could split the logic and use the error for reporting and let someone else (the root command?) to handle it by attempting binary provisioning.

@mstoykov mstoykov force-pushed the basicNativeNativeBinaryProvisioning branch from 38432f1 to ca4a183 Compare October 24, 2025 15:54
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 24, 2025 16:01 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 24, 2025 16:02 — with GitHub Actions Inactive
@mstoykov mstoykov requested a review from codebien October 27, 2025 08:54
codebien
codebien previously approved these changes Oct 27, 2025
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 27, 2025 10:07 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 27, 2025 10:09 — with GitHub Actions Inactive
oleiade
oleiade previously approved these changes Oct 28, 2025
@mstoykov mstoykov dismissed stale reviews from oleiade and codebien via 704b9c0 October 28, 2025 08:52
@mstoykov mstoykov requested review from codebien and oleiade October 28, 2025 08:52
@mstoykov mstoykov dismissed pablochacin’s stale review October 28, 2025 08:54

Everything has been changed

@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 28, 2025 08:58 — with GitHub Actions Inactive
@mstoykov mstoykov temporarily deployed to azure-trusted-signing October 28, 2025 09:00 — with GitHub Actions Inactive
}

// TODO(@mstoykov) potentially figure out some less "exceptionl workflow" solution
type binaryIsNotSatisfyingDependenciesError struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type binaryIsNotSatisfyingDependenciesError struct {
type binaryUnsatisfiedDependenciesError struct {

I don't want to block the pull request for it. But maybe in a another pr we should now align the error with the latest change.

@mstoykov mstoykov merged commit 0b22245 into master Oct 28, 2025
40 checks passed
@mstoykov mstoykov deleted the basicNativeNativeBinaryProvisioning branch October 28, 2025 09:25
@mstoykov mstoykov added breaking change for PRs that need to be mentioned in the breaking changes section of the release notes area: Auto Extension Resolution Previously known as binary provisioning. labels Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Auto Extension Resolution Previously known as binary provisioning. breaking change for PRs that need to be mentioned in the breaking changes section of the release notes

Projects

None yet

4 participants